package cn.burnit.view;


import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 用户界面
 */
public class UserMainForm extends JFrame {
    private JMenu maintain,borrowManage,checkManage,sysManage,bookInfoMaintain;
    private JMenuBar menuBar;
    private JMenuItem readerInfoMainatin,borrowBook,reurnBook,bookInfoCheck,readerInfoCheck
            ,addBook,updateBook,delBook
            ,personalInfo,checkpersonalInfo
            ,exitSys;
    private JLabel label;

//    public static void main(String[] args) {
//        new UserMainForm();
//    }
    public UserMainForm(){

        Container container = getContentPane();
        container.setLayout(null);
        label=new JLabel("欢迎进入图书管理系统");
        label.setFont(new Font("宋体", Font.PLAIN, 24));
        label.setBounds(180,100,300,100);
        label.setLayout(new FlowLayout(FlowLayout.CENTER));
        menuBar=new JMenuBar();
        maintain=new JMenu("基础维护");
        borrowManage=new JMenu("借阅管理");
        checkManage=new JMenu("查询管理");
        sysManage=new JMenu("系统管理");
        bookInfoMaintain=new JMenu("图书信息维护");
        maintain.setEnabled(false);//不能点击
        borrowManage.setEnabled(false);//不能点击

        readerInfoMainatin=new JMenuItem("读者信息维护");
        borrowBook=new JMenuItem("借书");
        reurnBook=new JMenuItem("还书");
        bookInfoCheck=new JMenuItem("图书信息查询");
        readerInfoCheck=new JMenuItem("读者信息查询");
        addBook=new JMenuItem("添加图书");
        updateBook=new JMenuItem("修改图书");
        delBook=new JMenuItem("删除图书");
        personalInfo=new JMenuItem("完善个人信息");
        checkpersonalInfo=new JMenuItem("查看个人信息");
        exitSys=new JMenuItem("退出系统");
        personalInfo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new PersonInfoForm();
            }
        });
        checkpersonalInfo.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new CheckPersonInfoForm();
            }
        });
        exitSys.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showConfirmDialog(null,"真的要退出系统吗？");
                new LoginForm();
                dispose();
            }
        });



        menuBar.add(maintain);
        menuBar.add(borrowManage);
        menuBar.add(checkManage);
        menuBar.add(sysManage);

        maintain.add(bookInfoMaintain);
        maintain.add(readerInfoMainatin);
        borrowManage.add(borrowBook);
        borrowManage.add(reurnBook);
        checkManage.add(bookInfoCheck);
        checkManage.add(readerInfoCheck);
        bookInfoMaintain.add(addBook);
        bookInfoMaintain.add(updateBook);
        bookInfoMaintain.add(delBook);
        sysManage.add(personalInfo);
        sysManage.add(checkpersonalInfo);
        sysManage.add(exitSys);

        setJMenuBar(menuBar);
        container.add(label);

        setTitle("图书管理系统");
        setSize(600,400);
        setLocationRelativeTo(null);
        setResizable(false);
        setVisible(true);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
}
